package com.qifei.dao;

import java.util.List;

import com.qifei.entity.Customer;

/**
 * 持久层
 * @author Administrator
 */
public class CustomerDaoImpl extends BaseDaoImpl<Customer> implements CustomerDao {

	/**
	 * 统计客户的来源
	 */
	public List<Object[]> findBySource() {
		// 定义HQL
		// SELECT * FROM cst_customer c,base_dict d WHERE d.dict_id = c.cust_source
		// 分组查询 SELECT * FROM cst_customer c,base_dict d WHERE d.dict_id = c.cust_source group by d.dict_id
		// 查询内容：SELECT d.dict_item_name,count(*) FROM cst_customer c,base_dict d WHERE d.dict_id = c.cust_source group by d.dict_id
		
		String hql = "select c.source.dict_item_name,count(*) from Customer c inner join c.source group by c.source";
		// 查询
		return (List<Object[]>) this.getHibernateTemplate().find(hql);
	}
	
}










